<?php 
namespace Phpcmf\Controllers;


class Chuangyejin extends \Phpcmf\Home\Module
{
    
    public function index() {
		$id = (int)\Phpcmf\Service::L('input')->get('id');
		$cid = (int)\Phpcmf\Service::L('input')->get('cid');
		if (!$this->uid) {
		    $rt=[
		    	'code'=>0,
		        'msg'=>'没有登陆',
		    	'data'=>'',
		    ];
		    //dr_return_data($rt['code'], $rt['msg'], $rt['data']);
			$this->_msg($rt['code'], $rt['msg'], $rt['data']);
		} elseif (!$id) {
			$rt=[
				'code'=>0,
			    'msg'=>'id参数不完整',
				'data'=>'',
			];
			$this->_msg($rt['code'], $rt['msg'], $rt['data']);
		}
        // 获取帖子数据
		$table = '1_quan_form_son';
		$tiedata =\Phpcmf\Service::M()->db->table($table)->where('id', $id)->where('fczt',1)->get()->getRowArray();
		
		$futiedata =\Phpcmf\Service::M()->db->table($table.'_data_0')->where('id', $id)->get()->getRowArray();
		if (!$tiedata) {
		    $rt=[
		    	'code'=>0,
		        'msg'=>'没有这个帖子',
		    	'data'=>'',
		    ];
		    $this->_msg($rt['code'], $rt['msg'], $rt['data']);
		} 
		
        $dataid=[
            'id'=> $tiedata['id'], //九格图
        ];

        // seo
		$datas = dr_string2array($tiedata);
		$fudata = dr_string2array($futiedata);
		//my-插件目录_模型名称-相关ID-数量-SKU参数值 （数量-SKU参数值可以忽略）
        \Phpcmf\Service::V()->assign(\Phpcmf\Service::L('Seo')->get_seo_value($datas, [
			'payform' => dr_payform("my-quan_chuangyejin-".$id),
			'datas' => $datas,
			'dataf' => $fudata,
            'meta_title' => isset($this->form['setting']['seo']['title']) && $this->form['setting']['seo']['title'] ? $this->form['setting']['seo']['title'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
            'meta_keywords' => isset($this->form['setting']['seo']['keywords']) && $this->form['setting']['seo']['keywords'] ? $this->form['setting']['seo']['keywords'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
            'meta_description' => isset($this->form['setting']['seo']['description']) && $this->form['setting']['seo']['description'] ? $this->form['setting']['seo']['description'] : $data['title'].SITE_SEOJOIN.dr_lang($this->form['name']),
        ]));
        
        \Phpcmf\Service::V()->display("mform_show-chuangyejin-buy.html");
		
    }
	public function zhifu() {
		$id = (int)\Phpcmf\Service::L('input')->get('id');
		$cid = (int)\Phpcmf\Service::L('input')->get('cid');
		if (!$cid) {
		    $rt=[
		    	'code'=>0,
		        'msg'=>'没有这个帖子',
		    	'data'=>'',
		    ];
		    return $this->_json($rt['code'], $rt['msg'], $rt['data']);
		} 
		$table = '1_quan_form_son_data_0';
		$sku = \Phpcmf\Service::M()->db->table($table)->where('id', $id)->get()->getRowArray();
		$skus = dr_string2array($sku);
		$skudata = dr_string2array($skus['fuchiguige']);
		$datas =dr_payform("my-quan_chuangyejin-".$id."-".$cid,);
		$data = [
			'data' => $datas,
			'feiyong'=>$skudata
		];
		$rt=[
			'code'=>1,
		    'msg'=>'支付页面',
			'data'=>$data,
		];
		
		return $this->_json($rt['code'], $rt['msg'], $rt['data']);
	}

	
}